﻿using System;
using System.Windows;
using System.Windows.Data;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Thinktecture.DataForm;
using Demo.Model;

namespace Demo
{
    public partial class DataFormWindow : Window
    {
        public DataFormWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // manually add sub data source
            //this.personDataForm.SetAssociationSource("Department", departments);
        }

        private void OnValidationError(object sender, Thinktecture.DataForm.DataFormValidationErrorEventArgs e)
        {
            //MessageBox.Show(e.PropertyName + ": " + e.ErrorMessage);
        }

        private void OnItemAdded(object sender, DataFormItemChangedEventArgs e)
        {
            this.eventTextBlock.Text = "Item added";
        }

        private void OnItemRemoved(object sender, DataFormItemChangedEventArgs e)
        {
            this.eventTextBlock.Text = "Item removed: " + ((Person)e.Item).Name;
        }

        private void OnItemChanged(object sender, DataFormItemChangedEventArgs e)
        {
            this.eventTextBlock.Text = "Item changed: " + ((Person)e.Item).Name;
        }

        private void cancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
